Skip to content

Add query route method support#60655

Open
Afcyy wants to merge 2 commits into
laravel:masterfrom
Afcyy:add-query-route-method-support
Open

Add query route method support#60655
Afcyy wants to merge 2 commits into
laravel:masterfrom
Afcyy:add-query-route-method-support

Conversation

@Afcyy

@Afcyy Afcyy commented Jul 3, 2026

Copy link
Copy Markdown

Re-targeting this to master after feedback on the previous PR (#60650).

This PR adds first-class routing support for the HTTP QUERY method.

Laravel already supports custom methods through Route::match() and Router::addRoute(), but there is no native Route::query() helper like there is for get, post, put, patch, delete, and options.

With this change, applications can define QUERY routes directly:

Route::query('/search', function () {
    return request()->input('filter');
});

QUERY is also included in Route::any(), exposed through the route registrar and facade docs, and treated as a read request by PreventRequestForgery.

That last part is important because QUERY is defined as a safe HTTP method, so it should behave like GET, HEAD, and OPTIONS for CSRF purposes.

Tests cover direct router dispatching, route registrar usage, framework integration, cached routes, and CSRF middleware behavior.

*/
public function query($uri, $action = null)
{
return $this->addRoute('QUERY', $uri, $action);

This comment was marked as resolved.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t believe HEAD should be added here

Laravel’s get() registers HEAD because RFC 9110 defines HEAD as identical to GET except no response body. RFC 10008 defines QUERY as its own method whose semantics depend on request content, so a HEAD request would not be equivalent to a QUERY request.

This also keeps it consistent with options(), which is safe but does not automatically register HEAD. Route::any() still includes both HEAD and QUERY through Router::$verbs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha! Thanks for the explanation 👍🏻

@Vectorial1024

Copy link
Copy Markdown

Concept first mentioned by issue #60564 ; not sure why it was a good idea to convert it into a discussion topic.

@Afcyy

Afcyy commented Jul 4, 2026

Copy link
Copy Markdown
Author

I think it would make sense that it went in Ideas because QUERY is a new HTTP method and adding a first-class route helper is a framework API addition.

At the same time, Laravel already has first-class helpers for common HTTP methods and QUERY now has a published Standards Track RFC. So I opened #60655 with a routing support-focused implementation: Route::query()

If the maintainers decide this should be included in the Laravel framework, this PR should address the original issue without extending the scope outside of routing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants